import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { NonQueryResult } from '../model/nonQueryResult';
import { Sentence } from '../model/sentence';
import { BaseService } from './base.service';
@Injectable({
  providedIn: 'root',
})
export class SentenceService extends BaseService {
  public constructor(http: HttpClient) {
    super(http);
  }

  public getSentencesByChapterNo(
    chapterNo: number = 1
  ): Observable<Sentence[]> {
    return this.get<Sentence[]>('/sentences/listByChapter/' + chapterNo);
  }

  public collectNewSentence(
    text: string,
    voiceType: string = 'en-US-JennyNeural'
  ): Observable<NonQueryResult> {
    return this.post<NonQueryResult>('/sentences/collect', {
      text,
      voiceType,
    });
  }
  public modify(sentence: Sentence) {
    return this.post('/sentences/modify', sentence);
  }
  public remove(id: string) {
    return this.post(`/sentences/remove/${id}`, '');
  }
}
